package com.douban.app.handller;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.Date;

@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        //填充时执行
        this.strictInsertFill(metaObject,"createTime", LocalDateTime.class,LocalDateTime.now());
//        this.strictUpdateFill(metaObject,"updateTime", LocalDateTime.class,LocalDateTime.now());
        this.strictInsertFill(metaObject,"name",String.class,"user");
        this.strictInsertFill(metaObject,"img",String.class,"https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3659063630,1193476131&fm=26&gp=0.jpg");
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        //更新时填充
        this.strictUpdateFill(metaObject,"updateTime", LocalDateTime.class,LocalDateTime.now());
    }
}
